import {
  type Accessor,
  createEffect,
  createMemo,
  createRenderEffect,
  on,
  onCleanup,
} from "solid-js";

const fLoading = (el: Element, value: Accessor<boolean>) => {
  createRenderEffect(() => {
    if (el) {
      console.log(
        "in fLoading",
        el,
        "parent El",
        el.parentElement,
        "parent Node",
        el.parentNode
      );

      const parentElement = el.parentElement
    }
  });

  const loading = createMemo(() => {
    return value();
  });

  createEffect(
    on(value, (loading) => {
      console.log("loading changed", loading);
    })
    // () => console.log("loading changed", loading())
  );

  onCleanup(() => {
    console.log("fLoading out");
  });
};

export default fLoading;
